package com.eqs.enterprisequestionnaire.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.eqs.enterprisequestionnaire.mapper.RoleMapper;
import com.eqs.enterprisequestionnaire.model.pojo.Role;
import com.eqs.enterprisequestionnaire.model.pojo.User;
import com.eqs.enterprisequestionnaire.service.RoleService;
import com.eqs.enterprisequestionnaire.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService {
    @Autowired
    RoleMapper roleMapper;

    @Autowired
    UserService userService;
    public Role getByRoleName(String name)
    {
        QueryWrapper<Role> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("name",name);
        return roleMapper.selectOne(queryWrapper);
    }
    public boolean isHasRole(User user,String role){
        return user.getRoleName().equals(role);
    }

}
